//
//  ImageViewUtil.swift
//  Extend
//
//  Created by 郑浩 on 2017/10/18.
//  Copyright © 2017年 敬信. All rights reserved.
//

import UIKit

public extension UIImageView {
    ///   动画
    ///
    /// - Parameters:
    ///   - names: 图片名称
    ///   - count: 图片数量
    public func animation(ImageName names: String, ImageCount count: Int) {
        var imageArray = [AnyHashable]()
        for i in 1..<count {
            let name = "\(names)\(i).png"
            let image = UIImage(named: name)
            imageArray.append(image!)
            self.animationImages = imageArray as? [UIImage]
            self.animationDuration = Double(imageArray.count) * 0.1
            self.animationRepeatCount = 0
            self.startAnimating()
        }
    }
    
    /// 停止动画
    public func stopAnimation() {
        if (self.isAnimating) {
            self.stopAnimating()
        }
    }
}
